package leetcodecompetition.D374;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

/**
 * @Author: Siantar
 * @Date: 2023-12-03-10:39
 * @Description: 1.0
 */
public class T100153 {
    public int minimumAddedCoins(int[] coins, int target) {
        Arrays.sort(coins);
        long p = 0;
        int res = 0;
        for (int num : coins) {
            while (p < target && num > p + 1) {
                System.out.println(p + 1);
                p += p + 1;
                res++;
            }
            p += num;
        }
        while (p < target) {
            System.out.println(p + 1);
            p += p + 1;
            res++;
        }
        return res;
    }
//    [6,4,1,9,9,2,10,7]
//            48
    @Test
    public void test() {
        System.out.println(minimumAddedCoins(new int[]{1,2,4,6,7,9,9,10},48));
    }
}
